home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Optical Alignment.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  1.8 KB  |  82 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17.  
  18. #include "SampleInterface.h"
  19.  
  20. short MyStrLen(char *x);
  21. static short MyStrLen(x)
  22. char    *x;
  23.     {
  24.     short c = 0;
  25.     while (*x++) c++;
  26.     return c;
  27.     }    /* MyStrLen */
  28.  
  29. void OpticalAlignment(WindowPtr sampleWindow)
  30.     {
  31.     /* Variables */
  32.     char            *myString = "Oh, NOOO";
  33.     gxLayoutOptions    gxLayoutOptions;
  34.     gxLine            myLine;
  35.     gxPoint            myPoint;
  36.     gxRunControls        gxRunControls;
  37.     gxShape            layout;
  38.     short            len, level = 0;
  39.     gxStyle            myStyle;
  40.     gxViewPort        aViewPort;
  41.     
  42.     /* Initialization */
  43.     
  44.     myPoint.x = ff(20);
  45.     myPoint.y = ff(50);
  46.     
  47.     aViewPort = GXNewWindowViewPort(sampleWindow);
  48.     SetDefaultViewPort(aViewPort);
  49.     
  50.     len = MyStrLen(myString);
  51.     InitializeRunControls(&gxRunControls);
  52.     InitializeLayoutOptions(&gxLayoutOptions);
  53.     gxLayoutOptions.width = ff(300);
  54.     gxLayoutOptions.just = fract1;
  55.  
  56.     myLine.first.x = myLine.last.x = myPoint.x;
  57.     myLine.first.y = 0;
  58.     myLine.last.y = ff(1000);
  59.     GXDrawLine(&myLine);
  60.     
  61.     myLine.first.x = myLine.last.x = myPoint.x + gxLayoutOptions.width;
  62.     GXDrawLine(&myLine);
  63.     
  64.     myStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  65.     
  66.     layout = GXNewLayout(
  67.         1, &len, (void *) &myString,
  68.         1, &len, &myStyle,
  69.         1, &len, &level,
  70.         &gxLayoutOptions, &myPoint);
  71.     GXDrawShape(layout);
  72.     
  73.     gxRunControls.flags = gxNoOpticalAlignment;
  74.     GXSetStyleRunControls(myStyle, &gxRunControls);
  75.     GXMoveShape(layout, 0, ff(75));
  76.     GXDrawShape(layout);
  77.     
  78.     GXDisposeShape(layout);
  79.     GXDisposeStyle(myStyle);
  80.     GXDisposeViewPort(aViewPort);
  81.     }    /* main */
  82.